
/**
 *SWF加壳实例 
 *	 www.sqstudio.com
 * @author Nestor
 * 
 * 
 * 项目文件.actionScriptProperties文件中注意编译顺序，InitMain 必须位于主程序TestMain之后
 * 
 *   <applications>
    <application path="Loading.as"/>
    <application path="TestMain.as"/>
    <application path="InitMain.as"/>
  </applications>
 * 
 * 
 * 
 * 
 */	
package
{
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import flash.text.TextField;

	[SWF(width="800",height="600")]
	public class Loading extends Sprite
	{

		private var loader:Loader;
		private var initMain:*;
		private var main:*;
		public function Loading()
		{
			var loadContext:LoaderContext=new LoaderContext();
			loadContext.applicationDomain=ApplicationDomain.currentDomain;
			loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,comHandler);
			loader.load(new URLRequest("InitMain.swf"),loadContext);
			
		}
		
		private function comHandler(e:Event):void
		{
			var info:LoaderInfo=LoaderInfo(e.target);
			var domain:ApplicationDomain=info.applicationDomain;
			var initMainClass:Class=domain.getDefinition("InitMain") as Class;
			initMain=new initMainClass();
			initMain.callback=loadMainCompleteFunc;
			initMain.start();
		}
		private function loadMainCompleteFunc(_main:Class):void
		{
			var manorPanelcc:Class=_main;
			main=new manorPanelcc();
			addChild(DisplayObject(main));
			stage.addEventListener(MouseEvent.CLICK,ckHandler);
		}
		
		private function ckHandler(e:MouseEvent):void
		{
			// TODO Auto-generated method stub
			main.update();
		}
	}
}